<?php
namespace app\admin\controller;


use think\Controller;

class Delcache extends Systemcontrol
{
  public function index(){
//      echo LOG_PATH;
//      echo CACHE_PATH;
//      echo TEMP_PATH;
      $this->deldir(CACHE_PATH);
      $this->deldir(TEMP_PATH);
      $this->deldir(LOG_PATH);
      $this->success ( "删除成功" );
  }
    function deldir($dir) {
        if(!is_dir($dir)) return;
        $dh = opendir($dir);
        while ($file = readdir($dh)) {
            if ($file != "." && $file != "..") {
                $fullpath = $dir . "/" . $file;

                if (!is_dir($fullpath)) {
                   unlink($fullpath);
                } else {
                    $this->deldir($fullpath);
                }
            }
        }
    }
}